package com.clei.dto.geo;

import java.util.Objects;

/**
 * 坐标Point
 *
 * @author Y
 * @date 2022-05-07
 */
public class Point {

    private static final double DOUBLE_ZERO_EQUALS_VALUE = 1.0E-6;

    /**
     * 经度
     */
    private Double longitude;

    /**
     * 纬度
     */
    private Double latitude;

    public Point() {
    }

    public Point(Double longitude, Double latitude) {
        super();
        this.longitude = longitude;
        this.latitude = latitude;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Point)) {
            return false;
        }
        Point point = (Point) o;
        return Math.abs(point.getLatitude() - getLatitude()) < DOUBLE_ZERO_EQUALS_VALUE
                && Math.abs(point.getLongitude() - getLongitude()) < DOUBLE_ZERO_EQUALS_VALUE;
    }

    @Override
    public int hashCode() {
        return Objects.hash(getLongitude(), getLatitude());
    }

    @Override
    public String toString() {
        return "Point{"
                + "longitude=" + longitude
                + ", latitude=" + latitude
                + '}';
    }
}
